<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
	function checkForm() {
		$("#rform1").submit()
	}
	function checkOnblurUsername() {
		var usernmae = $("#username").val();
		var msg = $("#usernameMsg");
		$.ajax({
			url:"${pageContext.request.contextPath}/checkUsername.do",
			type:"POST",
			contentType:'application/json',
			data:{username:usernmae},
			dataType:"json",
			error:function(data){
				$("#register").innerHTML="请求失败"
			},
			success:function (data) {
				if (data.flag == true) {
					msg.html("用户名可以注册");
					msg.css({"color":"green"})
				}else {
					msg.html("用户名不能注册");
					msg.css({"color":"red"})
				}
			}
		})
	}
	function checkOnblurEmail() {
		var email = $("#email").val();
		var msg = $("#emailMsg");
		$.ajax({
			url:"${pageContext.request.contextPath}/checkEmail.do",
			type:"POST",
			contentType:'application/json',
			data:{email:email},
			dataType:"json",
			error:function(data){
				$("#register").innerHTML="请求失败"
			},
			success:function (data) {
				if (data.flag == true) {
					msg.html("邮箱可以注册");
					msg.css({"color":"green"})
				}else{
					msg.html("邮箱不能注册");
					msg.css({"color":"red"})
				}
			}
		})
	}
</script>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>

		<meta charset="UTF-8">
		<title>俗谣雅玖-登陆注册</title>
		<link href="${pageContext.request.contextPath}/images/logo.ico" rel="icon" type="image/x-ico">
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/login.css">
		<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
		<link rel='stylesheet prefetch' href='https://fonts.googleapis.com/icon?family=Material+Icons'>

	</head>

	<body>

		<div class="cotn_principal">

			<div class="cont_centrar">
				<div class="cont_login">
					<div class="cont_info_log_sign_up">
						<div class="col_md_login">
							<div class="cont_ba_opcitiy">
								<h2>登&nbsp;&nbsp;&nbsp;录</h2>
								<p id="login">如果没有账号请先注册.</p>
								<button class="btn_login" onClick="cambiar_login()">登&nbsp;&nbsp;&nbsp;录</button>
							</div>
						</div>
						<div class="col_md_sign_up">

							<div class="cont_ba_opcitiy">
								<h2>注&nbsp;&nbsp;&nbsp;册</h2>
								<p id="register">如果已有账号请直接登录.</p>
								<button class="btn_sign_up" onClick="cambiar_sign_up()">注&nbsp;&nbsp;&nbsp;册</button>
							</div>
						</div>
					</div>
					<div class="cont_back_info">
						<div class="cont_img_back_grey"> <img src="${pageContext.request.contextPath}/images/po.jpg" alt="" /> </div>
					</div>
					<div class="cont_forms">
						<div class="cont_img_back_"> <img src="${pageContext.request.contextPath}/images/po.jpg" alt="" /> </div>
						<form id="lfrom1" action="${pageContext.request.contextPath}/login.do" method="post">
						<div class="cont_form_login">
							<a href="#" onClick="ocultar_login_sign_up()"><i class="material-icons">&#xE5C4;</i></a>
							<h2>登录</h2>
							<input type="text" placeholder="用户名" name="username"/>
							<input type="password" placeholder="密码" name="password" />
							<input type="submit" class="btn_login" onClick="cambiar_login()" value="登录"/>
						</div>
						</form>
						<form id="rform1" action="${pageContext.request.contextPath}/register.do" method="post" onsubmit="return checkForm();">
						<div class="cont_form_sign_up">
							<a href="#" onClick="ocultar_login_sign_up()"><i class="material-icons">&#xE5C4;</i></a>
							<h2>注册</h2>
							<input type="text" placeholder="邮箱" name="email" onblur="checkOnblurEmail()"/>
							<input type="text" placeholder="用户名" name="username" onblur="checkOnblurUsername()"/>
							<input type="password" placeholder="密码" name="password"/>
							<input type="password" placeholder="确认密码" />
							<input type="submit" class="btn_sign_up" onClick="cambiar_sign_up()" value="注册"/>
						</div>
						</form>
					</div>
				</div>
			</div>

		</div>

		<script src="${pageContext.request.contextPath}/js/index.js"></script>

	</body>

</html>